<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8" />
		<title>用户协议&隐私政策</title>
		<meta content="width=device-width,initial-scale=1.0,maximum-scale=1.0,user-scalable=no" name="viewport" />
		<style type="text/css">
			* {
				margin: 0;
				padding: 0;
			}

			textarea {
				border: none;
				width: 100vw;
				height: 100vh;
				box-sizing: border-box;
				padding: 20px;
				background-color: #FFFFFF;
				color: #333333;
				font-size: 14px;
				line-height: 20px;
			}
		</style>
	</head>
	<body>
		<div id="div"></div>
	</body>
</html>
<script type="text/javascript">
	const url = 'https://app.aixinfang.vip/user/userAgreement?agreeId='
	// const url = 'https://note.zjut.club/user/userAgreement?agreeId='

	function parseQueryString(url) {
		const urlKey = url.split('?')[1]
		const objKeyValue = {}
		if (!urlKey) return objKeyValue
		const urlObj = urlKey.split('&')
		for (let i = 0; i < urlObj.length; i++) {
			objKeyValue[urlObj[i].split('=')[0]] = decodeURI(urlObj[i].split('=')[1])
		}
		return objKeyValue
	}
	const urlParams = parseQueryString(window.location.href)
	let _id = urlParams.type == 2 ? 'zknboyaitksthudndlvrxrsivbeddfkiggvftvhvizauasdzfbwxykgdldbbutaq' :
		'fecmzvefuiezpvhdfwsocbvpcdzroruxnbaynnczphyagouiayrwtbzhuhbuhuem'
	let _url = url + _id
	/* url转字符串 */
	const httpRequest = new XMLHttpRequest() //第一步：创建需要的对象
	httpRequest.open('get', _url, true) //第二步：打开连接/***发送json格式文件必须设置请求头 ；如下 - */
	// 获取数据后的处理程序
	console.log(_id)
	httpRequest.onreadystatechange = function() { //请求后的回调接口，可将请求成功后要执行的程序写在其中
		console.log(httpRequest)
		if (httpRequest.readyState == XMLHttpRequest.DONE && httpRequest.status == 200) { //验证请求是否发送成功
			const res = JSON.parse(httpRequest.responseText) //获取到服务端返回的数据
			console.log(res)
			if (res.status == 0) {
				// window.onload = function() {
				// 	alert（ insertDiv.innerHTML）
				// 	insertDiv.innerHTML = "<p>This is inserted.</p>"
				// }
				document.getElementById('div').innerHTML = res.body.text
			}
		}
	}
	httpRequest.send(null) //发送请求 将json写入send中
</script>
